package IOStreamStudy.properties;

import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Properties;

/**
 * 对properties文件进行操作
 * 一些常规方法
 * */

public class PropertiesReadDemo {
    public static void main(String[] args) throws IOException {
        String filePath = "D:\\all_projects\\java_projects\\java_ij\\springMVC\\NetWork" +
                "\\src\\cn\\usts\\edu\\IOStreamStudy\\properties\\mysql.properties";
        FileReader fileReader = new FileReader(filePath);
        Properties properties = new Properties();
        properties.load(fileReader);
        properties.list(System.out);
        PrintWriter printWriter = new PrintWriter("D:\\all_projects\\java_projects\\java_ij\\springMVC\\NetWork\\src" +
                "\\cn\\usts\\edu\\IOStreamStudy\\properties\\a.txt");
        properties.list(printWriter);// 输出到指定文件中
        printWriter.close();
        System.out.println("---------------------------------");
        System.out.println("usr="+properties.getProperty("usr"));
        System.out.println("psd="+properties.getProperty("psd"));
        System.out.println("ip="+properties.getProperty("ip"));


    }
}
